<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/18
 * Time: 16:00
 */

namespace Home\Controller;


class ContactController extends HomeController
{
    public function index(){
        $meta=array(
            'meta_title'=>C("WEB_SITE_TITLE"),
            'keywords'  =>C("WEB_SITE_KEYWORD"),
            'description'=>C("WEB_SITE_DESCRIPTION"),
            'template_index'=>"Contact/index",
        );
        $this->assign("meta",$meta);
        $this->display();
    }

    public function feedback(){
        $meta=array(
            'meta_title'=>C("WEB_SITE_TITLE"),
            'keywords'  =>C("WEB_SITE_KEYWORD"),
            'description'=>C("WEB_SITE_DESCRIPTION"),
            'template_index'=>"Contact/index",
        );
        $this->assign("meta",$meta);
        if(IS_AJAX){
            $contact=D("Contact");
            if($contact->create()){
                if($contact->add()){
                    echo "留言成功";exit;
                }else{
                    echo "留言失败";exit;
                }
            }else{
                exit($contact->getError());
            }
        }else{
            $this->display();
        }
    }
}